<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">
        <h3>Modify Venue</h3>
                <h:form id="venueUpdateForm">
                    <p:dataTable value="#{stakeholderPerformanceMB.getAllVenues()}" var="venue"
                                 onRowSelectUpdate="venueUpdateForm"
                                 selection="#{stakeholderPerformanceMB.venue}"
                                 selectionMode="single"
                                 rowSelectListener="#{stakeholderPerformanceMB.updateSelectedVenueFields()}"
                                 styleClass="order-table"
                                 paginator="true"
                                 rows="5"
                                 >

                        <p:column>
                            <f:facet name="header">Venue Name</f:facet>
                            <h:outputText id="name" value="#{venue.name}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">Address</f:facet>
                            <h:outputText id="commissionPercent" value="#{venue.address}"  />
                        </p:column>

                        <p:column>
                            <f:facet name="header">Capacity</f:facet>         
                            <h:outputText value="#{venue.capacityCap}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">Latitude</f:facet>
                            <h:outputText value="#{venue.latitude}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">Longitude</f:facet>
                            <h:outputText value="#{venue.longitude}" />
                        </p:column> 

                        <p:column>
                            <f:facet name="header">Status</f:facet>
                            <h:outputText value="#{venue.active}" />
                        </p:column>
                    </p:dataTable>
                    <br/>
                    <h3>Click on a row above to edit a Venue</h3>
                    <h:panelGrid>
                        <p:ajaxStatus style="width:16px;height:16px;">
                            <f:facet name="start">
                                <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                            </f:facet>
                            <f:facet name="complete">
                                <h:outputText value="" />
                            </f:facet>
                        </p:ajaxStatus>
                        <p:messages />
                            <h:outputLabel for="venueName" value="Venue name: "/>
                            <h:outputLabel id="venueName" value="#{stakeholderPerformanceMB.venueName}"/>
                            <p:message for="venueName"/>
                            <br/>
                            <h:outputLabel for="venueAddress" value= "Venue address: "/>
                            <p:inputTextarea required="true" requiredMessage="Address required!"
                                             id="venueAddress" value="#{stakeholderPerformanceMB.venueAddress}"/>
                            <p:message for="venueAddress"/><br/>

                            <h:outputLabel for="venueLayout" value= "Venue Layout: "/>

                            <p:graphicImage id="venueLayout" value="./../../#{stakeholderPerformanceMB.venueLayout}" width="100" height="100"/>

                            <p:message for="venueLayout"/>
                            <h:outputText value="Upload Image: "/><br/>
                            <h:form enctype="multipart/form-data" prependId="false">
                                <p:fileUpload fileUploadListener="#{photoManagedBean.handleVenuePhotoUpload}" multiple="false" label="Browse" auto="true" allowTypes="*.jpg;*.png;*.gif;" description="Images" update="venueUpdateForm:pic" />
                            </h:form>


                            <br/>
                            <p:graphicImage id="pic" value="#{photoManagedBean.photoFilePath}" height="100"
                                            width="100"/><br/>

                            <h:outputLabel for="venueCapacity" value= "Venue Capacity: "/>
                            <p:inputText required="true" requiredMessage="Capacity required"
                                         id="venueCapacity" value="#{stakeholderPerformanceMB.venueCapacity}">
                            </p:inputText>   
                            <p:message for="venueCapacity"/><br/>

                            <h:outputLabel for="venueLatitude" value= "Venue Latitude: "/>
                            <p:inputText required="true" requiredMessage="Latitude required"
                                         id="venueLatitude" value="#{stakeholderPerformanceMB.venueLatitude}">

                            </p:inputText>
                            <p:message for="venueLatitude"/><br/>

                            <h:outputLabel for="venueLongtitude" value= "Venue Longtitude: "/>
                            <p:inputText required="true" requiredMessage="Longtitude required"
                                         id="venueLongtitude" value="#{stakeholderPerformanceMB.venueLongtitude}">

                            </p:inputText>   
                            <p:message for="venueLongtitude"/><br/>

                            <h:outputLabel for="venueStatus" value= "Venue Status: "/>
                            <h:selectOneMenu id="venueStatus" style="width: 260px" value="#{stakeholderPerformanceMB.venueStatus}" requiredMessage="Status required!" required="true">
                                <f:selectItem itemLabel="Select One..." itemValue= ""/>
                                <f:selectItem itemLabel="Active" itemValue="Active"/>
                                <f:selectItem itemLabel="Inactive" itemValue="Inactive"/>
                            </h:selectOneMenu>
                            <p:message for="venueStatus"/>

                     
                        <br/>

                        <br/>
                        <h:commandButton id="submitNewVenue" value="Modify Venue" onclick="if (!confirm('Are you sure you want to modify venue #{stakeholderPerformanceMB.venueName}?')) return false"
                                         action="#{stakeholderPerformanceMB.modifyVenue(event)}" >
                            <f:setPropertyActionListener target="#{stakeholderPerformanceMB.venueLayout}" value="#{photoManagedBean.photoFilePath}" />
                        </h:commandButton>
                        </h:panelGrid>
                </h:form>    
             </ui:define>
</ui:composition>
